<template>
  <div class="contact-panel">
    <div class="title">最近联系人</div>
    <div class="list">
      <div class="item" v-for="(contact, index) in contacts" :key="index" @click="selectContact(contact)">
        <el-badge :value="contact.badge||''">
          <img class="avatar" src="../../../assets/avatar.jpg" alt="">
        </el-badge>
        <span class="usercode">{{contact.UserCode}}</span>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
  import {Component, Vue} from 'vue-property-decorator'
  import { mapState, mapActions } from 'vuex'
  @Component({
    components: {},
    computed: {
      ...mapState({
        contacts: state => state.chat.contacts
      })
    },
    methods: {
      ...mapActions({
        selectContact: 'chat/selectContact'
      })
    }
  })
  export default class ContactPanel extends Vue {

  }
</script>

<style lang="scss" scoped>
  .contact-panel{
    padding: 15px;
    .list{
      .item:first-child{
        border-top: 1px solid #ebeef5;
      }
      .item{
        height: 40px;
        border-bottom: 1px solid #ebeef5;
        display: flex;
        align-items: center;
        cursor: pointer;
        padding: 10px;
        .avatar{
          width: 36px;
          height: 36px;
          -webkit-border-radius: 50%;
          -moz-border-radius: 50%;
          border-radius: 50%;
          margin-right: 10px;
        }
      }
    }
    .title{
      text-align: center;
      font-size: 16px;
      margin: 10px 0 20px 10px;
    }
  }
</style>
